<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
      
        /* 
        原型对象：Javascript的继承是基于原型的继承
        call 实现属性的继承
        */
        function Person(name,age){
            this.name = name;   // this指向 父构造函数的实例对象
            this.age = age
        }
        Person.prototype.sayName = function(){
            console.log(this.name);
        }
        
        function Teacher(name,age,skill){
           
            Person.call(this,name,age)  // Person(name,age) 中的this指向window
            this.skill = skill   // this指向 子构造函数的实例对象
        }
        
        Teacher.prototype = Person.prototype
        Teacher.prototype.constructor = Teacher

        Teacher.prototype.sayAge = function(){    
            console.log(this.age);  
        }
        // 方法的继承
        //  Teacher.prototype = new Person()  
        
        var t = new Teacher("zhang",18,"js")
        var p = new Person("lisi",13)
        console.log(t);
        t.sayName()
        t.sayAge()
    </script>
</body>
</html>